<?php 

$connection=mysql_connect('mysql.webio.pl', '2217_endq', 'flash2023*');
		if ($connection){
			if (!mysql_select_db('2217_endqtest', $connection)){
				echo "Can\'t choose db";
			}
		}else{
			echo "Connection error";
		}	


  if(isset($_POST['send'])) {
    if(mysql_num_rows(mysql_query("SELECT name FROM user WHERE name='".$_POST['login']."'")) == 0) {
    
    	   $log = $_POST['login'];
    	   $pass = $_POST['password'];
    	   
 		   mysql_query("insert into user set name='$log', password='$pass'");
   			
           $_SESSION['loginen'] = true;
           $_SESSION['login'] = $_POST['login'];
           $_SESSION['password'] = $_POST['password'];
           
           header('Location: '.Communicator::$location.'');
     } else { 
        echo "<br/><b>Taki uzytkownik juz istnieje.</b><br/>";
	 }
   }

?>
<br/>
	<b>Zarejestruj sie </b> <br/><br/>
	<form method='POST' action='?page=register'>
	<table>
	  <tr>
	    <td style="width:150px;">Nazwa uzytkownika:</td>
	    <td><input class="formElement" type="text" value=""  name='login'/></td>
	  </tr>
	  <tr>
	    <td>Haslo:</td>
	    <td><input class="formElement" type="password" value="" name='password' /></td>
	  </tr>
	</table>
	<br/>
	<input type="submit" value="Zarejestruj sie" name="send" />
	</form> 
	<br/>